package com.epic.followup.controller.wechat;

import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSONObject;
import com.epic.followup.service.wechat.WechatPatientBodyInformationService;
import com.epic.followup.temporary.DealMessageResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("wechat/bodyInfo")
public class WechatPatientBodyInformationController {

    @Autowired
    private WechatPatientBodyInformationService wechatPatientBodyInformationService;

    @RequestMapping(value = "/saveorupdateInfo", method = RequestMethod.POST)
    @ResponseBody
    public DealMessageResponse saveorupdateInfo(@RequestBody JSONObject information, HttpSession session) {
        Long id = (Long) session.getAttribute("id");
        return wechatPatientBodyInformationService.saveorupdateInformation(id, information);
    }

    @RequestMapping(value = "/retrieveInfo", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject retrieveInfo(@RequestBody JSONObject information,HttpSession session) {
        Long id = (Long) session.getAttribute("id");
        return wechatPatientBodyInformationService.retrieveInformation(id, information);
    }

}
